package cn.webrx;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileStream1 {
    public static void main(String[] args) {
        //FileOutputStream 文件输出流，主要用来写入内容
        try (FileOutputStream fos = new FileOutputStream("t1.txt", true)) {
            fos.write("hello".getBytes());
            fos.write("\n".getBytes());
        } catch (Exception e) {

        }

        //FileInputStream 文件输入流，主要用来读取文件内容
        try (var fis = new FileInputStream("t1.txt")) {
            //fis.readAllBytes();
            //fis.read()
            //fis.read(buf)
            //fis.skip(1);//
            //System.out.println((char)fis.read());

            //fis.skip(2);
            //byte[] buf = new byte[2];
            //System.out.println(Arrays.toString(buf));
            //fis.read(buf);
            //System.out.println(Arrays.toString(buf));
            //System.out.println(new String(buf));

            //byte[] buf = fis.readAllBytes();
            //System.out.println(new String(buf));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
